// pages/activities/activities.js
var config=require("../../api/config")
var util=require("../../utils/util")

Page({
  /*页面的初始数据*/
  data: {
    show: false,
    statusBarHeight:'',
    mechList: []
  },
  /*生命周期函数--监听页面加载*/
  onLoad: function (options) {
    var that=this,sysinfo = wx.getSystemInfoSync();
    that.setData({statusBarHeight:sysinfo.statusBarHeight})
  },
  loadImg:function(res){
    wx.showLoading({})
    var that=this;
    that.setData({show:true})
    that.get_activity_mech()
  },
  nav_back:function(){
    wx.navigateBack({
      delta: 1,
      fail:function(){
        wx.switchTab({
          url: '../home/home',
        })
      }
    })
  },
  nav_detail:function(e){
    var id=e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../mechDetail/mechDetail?id='+id,
    })
  },
  // 分享
  onShareAppMessage:function(e){
    return{
      title: "新年回“家”领福利 百万奖金赠学子",
      path: '/pages/activities/activities',
      imageUrl: 'https://ossdev0.jiabala.com/pXwxbDTQSWKhi'
    }
  },
  onShareTimeline:function(){
    return{
      title: "新年回“家”领福利 百万奖金赠学子",
      imageUrl: 'https://ossdev0.jiabala.com/pXwxbDTQSWKhi'
    }
  },
  get_activity_mech:function(){
    wx.hideLoading({})
    var that=this;
    config.get_activity_mech({
      currentPage: 1,
      pageSize: 100
    }).then(res=>{
      if(res.data.code==200){
        that.setData({mechList:res.data.data.records})
      }else{
        util.page_show_toast(res.data.message,2000)
      }
    })
  },
})